package com.example.converter.config;

import com.example.converter.enums.VideoTypeEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.convert.converter.Converter;
import org.springframework.core.convert.converter.ConverterFactory;
import org.springframework.stereotype.Component;

/**
 * @author wangwc@wumart.com
 * @version v1.0.0
 * @date 2021-11-29 17:44
 */
@Component
public class StringToEnumConverterFactory implements ConverterFactory<String, Enum<?>> {
    @Override
    public <T extends Enum<?>> Converter<String, T> getConverter(Class<T> targetType) {
        if (targetType == VideoTypeEnum.class) {
            return (Converter<String, T>) new StringToEnumConverter2();
        }
        return null;
    }
}
